package rad.framework.mda.generator.template.maven;

import org.eclipse.uml2.uml.Model;
import rad.framework.mda.generator.util.*;

public class JpaPom
{
  protected static String nl;
  public static synchronized JpaPom create(String lineSeparator)
  {
    nl = lineSeparator;
    JpaPom result = new JpaPom();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL + "<project>" + NL + "\t<parent>" + NL + "\t\t<groupId>";
  protected final String TEXT_2 = "</groupId>" + NL + "\t\t<artifactId>";
  protected final String TEXT_3 = "</artifactId>" + NL + "\t\t<version>";
  protected final String TEXT_4 = "</version>" + NL + "\t</parent>" + NL + "\t<modelVersion>4.0.0</modelVersion>" + NL + "\t<artifactId>";
  protected final String TEXT_5 = "</artifactId>" + NL + "\t<packaging>jar</packaging>" + NL + "\t<name>";
  protected final String TEXT_6 = "</name>" + NL + "\t<description>JPA project for ";
  protected final String TEXT_7 = "</description>" + NL + "\t" + NL + "\t<dependencies>" + NL + "\t\t<dependency>" + NL + "\t\t\t<groupId>rad-framework</groupId>" + NL + "\t\t\t<artifactId>rad-framework-search</artifactId>" + NL + "\t\t\t<version>${rad-framework.version}</version>" + NL + "\t\t</dependency>" + NL + "\t</dependencies>" + NL + "\t" + NL + "\t<build>" + NL + "\t\t<plugins>" + NL + "\t\t\t<plugin>" + NL + "\t\t\t\t<groupId>org.codehaus.mojo</groupId>" + NL + "\t\t\t\t<artifactId>hibernate3-maven-plugin</artifactId>" + NL + "\t\t\t\t<version>2.2</version>" + NL + "\t\t\t\t<configuration>" + NL + "\t\t\t\t\t<componentProperties>" + NL + "\t\t\t\t\t\t<outputfilename>schema.create.${project.version}.ddl</outputfilename>" + NL + "\t\t\t\t\t</componentProperties>" + NL + "\t\t\t\t</configuration>" + NL + "\t\t\t\t<executions>" + NL + "\t\t\t\t\t<execution>" + NL + "\t\t\t\t\t\t<id>test-phase-execution</id>" + NL + "\t\t\t\t\t\t<phase>process-classes</phase>" + NL + "\t\t\t\t\t\t<goals>" + NL + "\t\t\t\t\t\t\t<goal>hbm2ddl</goal>" + NL + "\t\t\t\t\t\t</goals>" + NL + "\t\t\t\t\t\t<configuration>" + NL + "\t\t\t\t\t\t\t<components>" + NL + "\t\t\t\t\t\t\t\t<component>" + NL + "\t\t\t\t\t\t\t\t\t<name>hbm2ddl</name>" + NL + "\t\t\t\t\t\t\t\t\t<implementation>jpaconfiguration</implementation>" + NL + "\t\t\t\t\t\t\t\t\t<outputDirectory>target</outputDirectory>" + NL + "\t\t\t\t\t\t\t\t</component>" + NL + "\t\t\t\t\t\t\t</components>" + NL + "\t\t\t\t\t\t\t<componentProperties>" + NL + "\t\t\t\t\t\t\t\t<persistenceunit>";
  protected final String TEXT_8 = "</persistenceunit>" + NL + "\t\t\t\t\t\t\t\t<propertyfile>src/test/resources/hbm2ddl.properties</propertyfile>" + NL + "\t\t\t\t\t\t\t\t<scan-classes>true</scan-classes>" + NL + "\t\t\t\t\t\t\t\t<outputfilename>schema.create.${project.version}.ddl</outputfilename>" + NL + "\t\t\t\t\t\t\t\t<export>false</export>" + NL + "\t\t\t\t\t\t\t\t<format>true</format>" + NL + "\t\t\t\t\t\t\t\t<drop>false</drop>" + NL + "\t\t\t\t\t\t\t\t<create>true</create>" + NL + "\t\t\t\t\t\t\t\t<!--" + NL + "\t\t\t\t\t\t\t\t<update>true</update>" + NL + "\t\t\t\t\t\t\t\t-->" + NL + "\t\t\t\t\t\t\t</componentProperties>" + NL + "\t\t\t\t\t\t</configuration>" + NL + "\t\t\t\t\t</execution>" + NL + "\t\t\t\t</executions>" + NL + "\t\t\t</plugin>" + NL + "\t\t</plugins>" + NL + "\t</build>" + NL + "</project>";
  protected final String TEXT_9 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    

    Model uml2Model = (Model) argument;
    stringBuffer.append(TEXT_1);
    stringBuffer.append(MavenHelper.getGroupId(uml2Model));
    stringBuffer.append(TEXT_2);
    stringBuffer.append(MavenHelper.getParentId(uml2Model));
    stringBuffer.append(TEXT_3);
    stringBuffer.append(MavenHelper.getVersion(uml2Model));
    stringBuffer.append(TEXT_4);
    stringBuffer.append(MavenHelper.getArtifactId(uml2Model, "jpa"));
    stringBuffer.append(TEXT_5);
    stringBuffer.append(MavenHelper.getName(uml2Model, "JPA"));
    stringBuffer.append(TEXT_6);
    stringBuffer.append(uml2Model.getName());
    stringBuffer.append(TEXT_7);
    stringBuffer.append(uml2Model.getName());
    stringBuffer.append(TEXT_8);
    stringBuffer.append(TEXT_9);
    return stringBuffer.toString();
  }
}
